package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.BatchRepairFlow;
import com.indusfo.spc.service.BatchRepairFlowService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/12/6 9:46
 * @Version 1.0
 */

@Controller
@RequestMapping("/service/batchRepairFlow")
public class BatchRepairFlowController {

    @Autowired
    private BatchRepairFlowService batchRepairFlowService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryBatchRepairFlow")
    @ResponseBody
    public JSONObject queryBatchRepairFlow(BatchRepairFlow batchRepairFlow) {
        JSONObject json = batchRepairFlowService.queryBatchRepairFlow(batchRepairFlow);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertBatchRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertBatchRepairFlow(BatchRepairFlow batchRepairFlow) {
        JSONObject json = batchRepairFlowService.insertBatchRepairFlow(batchRepairFlow);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateBatchRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateBatchRepairFlow(BatchRepairFlow batchRepairFlow) {
        JSONObject json = batchRepairFlowService.updateBatchRepairFlow(batchRepairFlow);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteBatchRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteBatchRepairFlow(@RequestParam("batchRepairFlowIds") List<Integer> batchRepairFlowIds, Integer dataState) {
        dataState = 2;
        JSONObject json = batchRepairFlowService.deleteBatchRepairFlow(batchRepairFlowIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedBatchRepairFlow", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedBatchRepairFlow(@RequestParam("batchRepairFlowIds") List<Integer> batchRepairFlowIds, Integer dataState) {
        JSONObject json = batchRepairFlowService.deleteBatchRepairFlow(batchRepairFlowIds, dataState);
        return json;
    }

}
